package com.sheep.demo.quartz.dto;

import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;
import java.util.Map;

@Data
@EqualsAndHashCode(callSuper = true)
public class CreateRemoteCronJobDTO extends CreateRemoteJobDTO {

    private String cron;

    private LocalDateTime startTime;

    private LocalDateTime endTime;

    public Date getStartAt() {
        if (startTime == null) {
            return new Date();
        }
        // 使用系统默认时区
        ZoneId zoneId = ZoneId.systemDefault();
        return Date.from(startTime.atZone(zoneId).toInstant());
    }

    public Date getEndAt() {
        if (endTime == null) {
            return null;
        }
        // 使用系统默认时区
        ZoneId zoneId = ZoneId.systemDefault();
        return Date.from(endTime.atZone(zoneId).toInstant());
    }

}
